﻿using InvestmentIntelligence.DB.Utils.MergeExtension;
using InvestmentIntelligence.DbModel.Models;
using System;
using System.Collections.Generic;
using System.Linq;

namespace InvestmentIntelligence.Data.Repository
{
    public interface IOriginalPositionRepository : ISeriesRepository
    {
        /// <summary>
        /// Return Min trade date
        /// </summary>
        /// <returns></returns>
        DateTime? GetMinDate();

        /// <summary>
        /// Return MAX trade date
        /// </summary>
        /// <returns></returns>
        DateTime? GetMaxDate();

        /// <summary>
        ///     Return list of Original position entities
        /// </summary>
        /// <returns></returns>
        List<T> GetList<T>(Func<IQueryable<OriginalPosition>, IEnumerable<T>> f);

        List<T> GetListByBook<T>(Func<IQueryable<OriginalPosition>, IEnumerable<T>> f, int bookId);

        Dictionary<int, List<OriginalPosition>> GetLastPositions(int fundBookId, IEnumerable<int> securities);

        Dictionary<int, OriginalPosition> GetActivePositions(int fundBookId);

        IEnumerable<int> GetMostUsedSecurities();

        void MergeOverFundBookFromDate(IEnumerable<OriginalPosition> positions, int fundBookEntityId, DateTime fromDate, MergeOperationType mergeType);
    }
}